package com.ycfmedical.bed.utils;

import android.os.CountDownTimer;
import android.os.StrictMode;

import com.ycfmedical.bed.Constants;
import com.ycfmedical.bed.local.DataManager;
import com.ycfmedical.bed.serverdata.DBUtil;
import com.ycfmedical.bed.wifi.ClientThread;
import com.ycfmedical.bed.wifi.WifiEvent;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import cn.droidlover.xdroidmvp.log.XLog;

/**
 * Created by Administrator on 2017-04-24.
 */

public class ServerControl {


    /**
     * 获取服务器存取的一键体位数据
     *
     * @param postId
     * @return
     */
    public static String getQuicklyPostDate(int postId)
    {
        DBUtil dbUtil = DBUtil.getInstance();
        // 获取体位
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
        // 服务器返回一键体位数据
        String GetquicklyPostMsgG = dbUtil.get_tiwei(postId + "", DataManager.getInstance().getUser().getId() + "");
        return GetquicklyPostMsgG;
    }

    /**
     * 存储一键体位数据到数据库
     *
     * @param angleOrderMsg
     * @param quicklyPostId
     * @return
     */
    public static void SaveQuicklyPostDate(String angleOrderMsg, int quicklyPostId) {
        DBUtil dbUtil = DBUtil.getInstance();
        // 获取体位
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
        // 存储一键体位数据到数据库
        String SavequicklyPostMsg = dbUtil.update_tiwei(angleOrderMsg, quicklyPostId + "", DataManager.getInstance().getUser().getId() + "");
    }

    /**
     * 存储患者体温体重数据数据到数据库
     *
     * @param temperatureValue 体温或者体重数据
     * @param Mac              蓝牙设备Mac地址
     * @return
     */
    public static void SaveTmeAndWeight(String temperatureValue, String Mac) {
        DBUtil dbUtil = DBUtil.getInstance();
        // 获取体位
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
        String SavequicklyPostMsg = dbUtil.save_twtz(DataManager.getInstance().getUser().getId() + "", temperatureValue, Mac);

    }

}
